package org.vdab.projects.tasks.shared.entities.impl;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

import org.vdab.projects.tasks.shared.EntityManager;
import org.vdab.projects.tasks.shared.entities.IBaseEntity;
import org.vdab.projects.tasks.shared.entities.ITask;

@PersistenceCapable
public class Task extends BaseEntity<Task> implements ITask{
		
	@Persistent
	private String description;
	
	@SuppressWarnings("unused")
	//@Persistent(defaultFetchGroup = "true")
	//The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group.
	@Persistent	
	private TaskList parrentTaskList;
	
	@Override
	public String getDescription() {		
		return description;
	}

	@Override
	public Task setDescription(String description) {
		this.description = description;		
		return this;
	}

	@Override
	public String getDisplayText() {		
		return this.getDescription();
	}

	@Override
	public IBaseEntity<Task> save() throws Exception {
			EntityManager.get().saveTask(this);
		return this;
	}

	public void setParrent(TaskList taskList) {
		this.parrentTaskList = taskList;		
	}
}
